package org.edu.model;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Proxy;

@Entity
@Proxy(lazy = false)
@Table(name = "SEMESTERNOTES", catalog = "SCHOOL")
public class SemesterNotes implements Serializable {

	private static final long serialVersionUID = -607245976323129013L;

	private Long semester_notes_id;
	private Set<TeacherLesson> teacherLessons = new HashSet<>();
	private Set<TeacherProject> teacherProjects = new HashSet<>();
	private String semester;
	private Date semester_date;

	@Id
	@Column(name = "SEMESTER_NOTES_ID")
	@GeneratedValue
	public Long getSemester_notes_id() {
		return semester_notes_id;
	}

	public void setSemester_notes_id(Long semester_notes_id) {
		this.semester_notes_id = semester_notes_id;
	}
	
	@OneToMany(targetEntity = TeacherLesson.class, mappedBy = "semesterNotes", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	public Set<TeacherLesson> getTeacherLessons() {
		return teacherLessons;
	}

	public void setTeacherLessons(Set<TeacherLesson> teacherLessons) {
		this.teacherLessons = teacherLessons;
	}
	
	@OneToMany(targetEntity = TeacherProject.class, mappedBy = "semesterNotes", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	public Set<TeacherProject> getTeacherProjects() {
		return teacherProjects;
	}

	public void setTeacherProjects(Set<TeacherProject> teacherProjects) {
		this.teacherProjects = teacherProjects;
	}

	@Column(name = "SEMESTER", length = 25)
	public String getSemester() {
		return semester;
	}

	public void setSemester(String semester) {
		this.semester = semester;
	}

	@Column(name = "SEMESTER_DATE")
	public Date getSemester_date() {
		return semester_date;
	}

	public void setSemester_date(Date semester_date) {
		this.semester_date = semester_date;
	}

	public SemesterNotes() {
		super();
		// TODO Auto-generated constructor stub
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((semester == null) ? 0 : semester.hashCode());
		result = prime * result
				+ ((semester_date == null) ? 0 : semester_date.hashCode());
		result = prime
				* result
				+ ((semester_notes_id == null) ? 0 : semester_notes_id
						.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SemesterNotes other = (SemesterNotes) obj;
		if (semester == null) {
			if (other.semester != null)
				return false;
		} else if (!semester.equals(other.semester))
			return false;
		if (semester_date == null) {
			if (other.semester_date != null)
				return false;
		} else if (!semester_date.equals(other.semester_date))
			return false;
		if (semester_notes_id == null) {
			if (other.semester_notes_id != null)
				return false;
		} else if (!semester_notes_id.equals(other.semester_notes_id))
			return false;
		return true;
	}
	
}
